from flask import jsonify


class BooksResult():
    def __init__(self, books, count, start):
        self.books = books
        self.count = count
        self.start = start
        self.total = len(books)

    def to_json(self):
        result = {
            'books': self.books[self.start: self.start + self.count],
            'count': self.count,
            'start': self.start,
            'total': self.total
        }
        return jsonify(result)